Exponential ambiguity of context-free grammars
نویسنده
چکیده
A context-free grammar G is ambiguous if and only if there is a word that can be generated byG with at least two different derivation trees. Ambiguous grammars are often distinguished by their degree of ambiguity, which is the maximal number of derivation trees for the words generated by them. If there is no such upper bound G is said to be ambiguous of infinite degree. Here as a new tool for examining the ambiguity of cyclefree context-free grammars the ambiguity function is introduced. This function maps the natural number n to the maximal number of derivation trees which a word of length at most n may have. This provides the possibility to distinguish infinitely ambiguous context-free grammars by the growth-rate of their ambiguity functions. We present a necessary and sufficient, but in general undecidable, criterion for exponential ambiguity. In fact violation of this criterion leads to a polynomial upper bound for the ambiguity, which can be effectively constructed from the grammar. Hence for cycle-free context-free grammars the ambiguity function is either an element of 2 or of O(n) for some d ∈ N0 which can be effectively constructed from G.
منابع مشابه
Pattern Ambiguities for Pure Context{free Grammars Pattern Ambiguities for Pure Context{free Grammars Pattern Ambiguities for Pure Context{free Grammars
We consider here some special forms of ambiguity for pure context-free grammars, namely pattern avoiding ambiguity, pattern preserving ambiguity, pattern ambiguity, and grammar avoiding ambiguity. The rst two properties are undecidable for arbitrary pure context-free grammars, and in a particular but general enough case we can eeectively decide whether or not a pure context-free grammar is patt...
متن کاملAmbiguity Detection: Scaling towards Scannerless
Static ambiguity detection would be an important aspect of language workbenches for textual software languages. The challenge is that automatic ambiguity detection of context-free grammars is undecidable. Sophisticated approximations and optimizations do exist, but these do not scale to grammars for so-called “scannerless parsers”, as of yet. We extend previous work on ambiguity detection for c...
متن کاملAmbiguity Detection: Scaling to Scannerless
Static ambiguity detection would be an important aspect of language workbenches for textual software languages. However, the challenge is that automatic ambiguity detection in context-free grammars is undecidable in general. Sophisticated approximations and optimizations do exist, but these do not scale to grammars for so-called “scannerless parsers”, as of yet. We extend previous work on ambig...
متن کاملA Note on Ambiguity in Context-Free Grammars
We show that ambiguity in context-free grammars can be decomposed into union-ambiguity and concatenation-ambiguity. We also show that the traditional proof of the undecidability of ambiguity in context-free grammars addresses only one part of ambiguity, namely the union-ambiguity. We extend this result by showing that the concatenation-ambiguity is also undecidable. Context-free grammars (CFGs)...
متن کاملAnalyzing Ambiguity of Context-Free Grammars
It has been known since 1962 that the ambiguity problem for context-free grammars is undecidable. Ambiguity in context-free grammars is a recurring problem in language design and parser generation, as well as in applications where grammars are used as models of real-world physical structures. We observe that there is a simple linguistic characterization of the grammar ambiguity problem, and we ...
متن کامل